set sourceDir [file dir [info script]]

proc get_eset { res1 } {
	*createmarkpanel sets 1 "Select esets for put out"
	set mysets [ hm_getmark sets 1 ]
	*clearmark sets 1
	
	foreach setid $mysets {
		set name [ hm_getvalue sets id=$setid dataname=name ]
		set myelems [ hm_getentityarray sets $setid elements ]
		set elem_num [ llength $myelems ]
		puts $res1 "$setid,$name,$elem_num\n$myelems"
	}
}


proc write_out { } { 
	set types_r {
		{{eset Files}       {.eset}      }
		{{All Files}        *            }
	}
	set filename [ tk_getSaveFile -defaultextension "eset" -initialdir " " -filetypes $types_r -title "Save File as ..."]
	if { $filename == "" } { return }
	
	if [ catch { open "$filename" w} res1 ] {
		puts "Cannot open $filename for write:$res1"
	}
	
	get_eset $res1
	
	close $res1
	puts   "output : $filename"
}

write_out